<template>
  <div class="setting-container">
    <!-- Header Bar 用于切换各种设置 -->
    <div class="setting-header">
      <button 
        v-for="tab in tabs" 
        :key="tab.id"
        :class="['tab-button', { 'active': activeTab === tab.id }]"
        @click="switchTab(tab.id)"
      >
        {{ tab.label }}
      </button>
    </div>

    <!-- 主要显示内容区域 -->
    <div class="setting-content">
      <!-- 隐私政策内容区域 -->
      <div v-if="activeTab === 'privacy-policy'" class="policy-content">
        <PolicyPage />
      </div>
      
      <!-- 积分设置内容区域 -->
      <div v-if="activeTab === 'points-setting'" class="points-content">
        <CreditSettingPage />
      </div>
      
      <!-- 等级设置内容区域 -->
      <div v-if="activeTab === 'level-setting'" class="level-content">
        <LevelSettingPage />
      </div>
      
      <!-- 城市设置内容区域 -->
      <div v-if="activeTab === 'city-setting'" class="city-content">
        <CitySettingPage />
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import PolicyPage from './circle/setting/PolicyPage.vue';
import CreditSettingPage from './circle/setting/CreditSettingPage.vue';
import LevelSettingPage from './circle/setting/LevelSettingPage.vue';
import CitySettingPage from './circle/setting/CitySettingPage.vue';

// 定义选项卡数据
const tabs = [
  { id: 'privacy-policy', label: '政策协议' },
  { id: 'points-setting', label: '积分设置' },
  { id: 'level-setting', label: '等级设置' },
  { id: 'city-setting', label: '城市设置' },
];

// 当前激活的选项卡
const activeTab = ref('privacy-policy');

// 切换选项卡
const switchTab = (tabId: string) => {
  activeTab.value = tabId;
  // 显示切换提示
  if (window.showToast) {
    window.showToast?.(`已切换到${tabs.find(t => t.id === tabId)?.label}`, 'info', 2000);
  }
};
</script>

<style scoped>
/* Theme-aware styling */
.setting-container {
  background-color: var(--bg-primary);
  height: 100vh;
  min-height: 100vh;
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header Bar 样式 */
.setting-header {
  display: flex;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
  gap: 16px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

/* 选项卡按钮样式 */
.tab-button {
  padding: 10px 20px;
  background-color: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.3s ease;
}

.tab-button:hover {
  background-color: var(--bg-tertiary);
}

.tab-button.active {
  background-color: var(--accent-primary);
  border-color: var(--accent-primary);
  color: var(--text-inverse);
}

/* 内容区域样式 */
.setting-content {
  padding: 10px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* 各个页面内容区域 */
.policy-content,
.points-content,
.level-content,
.city-content {
  height: 100%;
  overflow: hidden;
}

/* 城市设置占位内容样式 */
.city-setting-placeholder {
  text-align: center;
  padding: 40px;
  background-color: var(--bg-secondary);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.city-setting-placeholder h3 {
  color: var(--text-primary);
  font-size: 20px;
  margin-bottom: 12px;
}

.city-setting-placeholder p {
  color: var(--text-secondary);
  font-size: 14px;
}

/* 滚动条样式 */
.setting-content::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.setting-content::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
  border-radius: 4px;
}

.setting-content::-webkit-scrollbar-thumb {
  background: var(--accent-primary);
  border-radius: 4px;
  opacity: 0.5;
}

.setting-content::-webkit-scrollbar-thumb:hover {
  opacity: 0.7;
}

</style>